package com.tedu.day01.oop;




import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class DogJPanel extends JPanel   implements Runnable{
                int x=300,y=50;
                Thread t;
                public DogJPanel(){
                	setBackground(Color.BLACK);
                	t=new Thread(this);
                	t.start();
                }
               
            public void paint(Graphics g) {
            super.paint(g);
           g.setColor(Color.WHITE);
           g.fillOval(50, 50, 100, 100);
           g.setColor(Color.black);
           g.fillOval(x,y ,100, 100);
            }
            public void run(){
            	for(;;){
            		x--;
            	if(x==75){
            		x=300;
            	}
            		
            		
            	
            	repaint();
            	try {
					Thread.sleep(10);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
            }
            }       
            
}
